package com.kelan.android.app.controller;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kelan.android.app.entity.AjaxResult;
import com.kelan.android.app.entity.EasyUIDataGridResult;
import com.kelan.android.app.entity.ScztxxEntity;
import com.kelan.android.app.service.ScztxxService;

import cn.hutool.core.util.IdUtil;

@Controller
public class ScztxxController {

	@Autowired
	private ScztxxService scztxxService;
	
	@RequestMapping("index")
	public String indexhtml() {
		return "indextest.html";
	}
	
	@RequestMapping("enteva")
	public String entevahtml() {
		return "enteva.html";
	}
	/**
	 * @Title: getStrList
	 * @Description: 查询监管企业信息 select * from BZ_SCZTXX T where 1=1
	 * @Author 刘仁
	 * @DateTime 2020年2月27日 下午12:40:23
	 * @return
	 */
	@GetMapping("scztxx")
	@ResponseBody
	public EasyUIDataGridResult getStrList(@RequestParam(value="page",required = true, defaultValue = "1") Integer pageNum ,
            @RequestParam(value="rows",required = true, defaultValue = "10") Integer rows, ScztxxEntity scztxxEntity){
		PageHelper.startPage(pageNum , rows);
		List<ScztxxEntity> list = scztxxService.selectScztxxList(scztxxEntity);
		PageInfo<ScztxxEntity> personPageInfo = new PageInfo<>(list);
		EasyUIDataGridResult dataGridResult = new EasyUIDataGridResult();
		dataGridResult.setTotal(Integer.parseInt(personPageInfo.getTotal()+""));
		dataGridResult.setRows(list);
		return dataGridResult;
	}
	
	@ResponseBody
	@PostMapping("addscztxx")
	public AjaxResult addScztxx(ScztxxEntity scztxxEntity) {
		scztxxEntity.setId(IdUtil.fastSimpleUUID());
		scztxxEntity.setUpdateTime(new Date());
		scztxxEntity.setBizOrg("SY");
		return AjaxResult.success(scztxxService.insertScztxx(scztxxEntity));
	}
	
	@ResponseBody
	@PostMapping("editscztxx")
	public AjaxResult editScztxx(ScztxxEntity scztxxEntity) {
		return AjaxResult.success(scztxxService.editScztxx(scztxxEntity));
	}
	
	@ResponseBody
	@PostMapping("delscztxx/{id}")
	public AjaxResult delScztxxById(@PathVariable String id) {
		return AjaxResult.success(scztxxService.delScztxxById(id));
	}
	
	@ResponseBody
	@GetMapping("scztxx/{id}")
	public AjaxResult scztxxById(@PathVariable String id) {
		return AjaxResult.success(scztxxService.selectScztxxById(id));
	}
}
